import requests

from two_code.xm25 import result


class youdao:
    def __init__(self,word):
        self.url="http://http://fanyi.youdao.com/translate_o?smartresult=direct&smartresult=rule"
        self.headers={
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36'
        }
        self.word=word
        self.data={
            'encrypt_key': 'password',
            'utf8': '✓',
            'authenticity_token': 'CuOr8Ia5lXxC0sEVZrM50YhSDLvf0Uvm0utdoJDI4gM=',
            'redirect_to_url': '',
            'user[login]': '2844369248@qq.com',
            'encrypt_data[user[password]]': 'N0o2jgBzlK5d3hwRO2DsoaxTrqdayILwfqrd+CQ1/MMX8v1sUszn4zIqxPX1MH2M9DIGco81bXGGw0Z1L/WQgJQ6neEdX8G3ckTyBojjwOEsX6Oxk3xOTzaeKiJ2UqYEPLkypyAW9V+ILOK9uNJOVgoF1S8ySevBj7spxJOpG6I=',
            'user[remember_me]': '0'
        }


        def get_data(self):
            data=requests.post(self.url,headers=self.headers,data=self.data)
            return result.content.decode()

fan1=youdao('hello')
print(fan1.get_data())
fan2=youdao('好好学习')
print(fan2.get_data())